package cn.js.sip.rat.system.service.impl;

import cn.js.sip.rat.system.entity.SysRoleEntity;
import cn.js.sip.rat.system.exception.BusinessException;
import cn.js.sip.rat.system.mapper.SysRoleMapper;
import cn.js.sip.rat.system.service.TestService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @ClassName: cn.js.sip.rat.system.service.impl
 * @Description: TODO
 * @author: xuxiaoli
 * @Date: 2020-01-07   14:13
 */
@Service("testService")
public class TestServiceImpl implements TestService {

    @Resource
    private SysRoleMapper sysRoleMapper;

    @Override
    @Transactional
    public void insert() {
        SysRoleEntity sysRoleEntity = new SysRoleEntity();
        sysRoleEntity.setRoleCode("123");
        sysRoleEntity.setRoleName("1232");
        sysRoleEntity.setId("sadasdasd");
        sysRoleEntity.setCreaterId("sada");
        sysRoleEntity.setCreaterTime(new Date());
        sysRoleMapper.insert(sysRoleEntity);

        if (true) {
            throw new BusinessException("sadasd");
        }
        SysRoleEntity sysRoleEntity2 = new SysRoleEntity();
        sysRoleEntity.setCreaterId("sada");
        sysRoleEntity.setCreaterTime(new Date());
        sysRoleEntity2.setRoleCode("12w23");
        sysRoleEntity2.setRoleName("1232");
        sysRoleEntity2.setId("sadasdasdd");
        sysRoleMapper.insert(sysRoleEntity2);
    }
}
